package org.ki.gra.aktorzy;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.scenes.scene2d.Actor;

/**
 * User: kieronsk
 * Date: 10/9/12
 * Time: 4:34 PM
 */
public class Kratownica extends Actor {

    private final ShapeRenderer renderer = new ShapeRenderer();

    public Kratownica() {
        this.x = 0;
        this.y = 0;
        this.height = 10;
        this.width = 10;
    }

    @Override
    public void draw(SpriteBatch batch, float parentAlpha) {
        batch.end();
        renderer.setProjectionMatrix(stage.getCamera().combined);
        renderer.begin(ShapeRenderer.ShapeType.Rectangle);
        renderer.setColor(Color.BLUE);
        for (int i=0; i<10; i++)
            for (int j=0; j<10; j++)
            renderer.rect(i, j, 1, 1);
        renderer.end();
        batch.begin();
    }

    @Override
    public Actor hit(float x, float y) {
        if (x>0 && x<this.width && y>0 && y<this.height)
            return this;
        return null;
    }
}
